//
//  UIAlertController+Ex.swift
//  GhostWorld
//
//  Created by Kam on 2018/5/14.
//  Copyright © 2018 LKGood. All rights reserved.
//

import UIKit

extension UIAlertController {
  convenience init(title: String, message: String?,
                   cancelTitle: String, cancelHandler: ((UIAlertAction) -> Void)?) {
    
    self.init(title: title, message: message, preferredStyle: .alert)
    
    let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel, handler: cancelHandler)
    addAction(cancelAction)
  }
  
  convenience init(title: String, message: String?, cancelTitle: String,
                   cancelHandler: ((UIAlertAction) -> Void)?,
                   confirmTitle: String, confirmHandler: ((UIAlertAction) -> Void)?) {
    
    self.init(title: title, message: message, preferredStyle: .alert)
    
    let cancelAction = UIAlertAction(title: cancelTitle, style: .default, handler: cancelHandler)
    addAction(cancelAction)
    
    let confirmAction = UIAlertAction(title: confirmTitle, style: .destructive, handler: confirmHandler)
    addAction(confirmAction)
  }
}
